cmake_minimum_required(VERSION 3.10)

project(use_hdf5)

set(HDF5_INCLUDE_DIR $ENV{HDF5_DIR}/include)
set(HDF5_LIB_DIR $ENV{HDF5_DIR}/lib)
if(NOT EXISTS "${HDF5_INCLUDE_DIR}/hdf5.h")
    message(FATAL_ERROR "HDF5 头文件未找到，请检查 HDF5_DIR 是否正确: ${HDF5_INCLUDE_DIR}")
endif()
set(HDF5_LIBRARY_C "${HDF5_LIB_DIR}/libhdf5.a")
if(NOT EXISTS "${HDF5_LIBRARY_C}")
    message(FATAL_ERROR "HDF5 库文件未找到，请检查 HDF5_DIR 是否正确: ${HDF5_LIBRARY_C}")
endif()

# set(ZLIB_INCLUDE_DIR $ENV{ZLIB_DIR}/include)
# set(ZLIB_LIBRARY $ENV{ZLIB_DIR}/lib/libz.so) 
# find_package(ZLIB REQUIRED)
# message(STATUS ${ZLIB_LIBRARY})
set(ZLIB_INCLUDE_DIR $ENV{ZLIB_DIR}/include)
set(ZLIB_LIBRARY $ENV{ZLIB_DIR}/lib/libz.so)
if(NOT EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h")
    message(FATAL_ERROR "ZLIB头文件未找到: ${ZLIB_INCLUDE_DIR}/zlib.h")
endif()
if(NOT EXISTS "${ZLIB_LIBRARY}")
    message(FATAL_ERROR "ZLIB库文件未找到: ${ZLIB_LIBRARY}")
endif()



include_directories(
    ${HDF5_INCLUDE_DIR}
    ${PROJECT_SOURCE_DIR}/libs
    ${ZLIB_INCLUDE_DIR}
)

link_libraries(
    ${HDF5_LIBRARY_C}
    ${ZLIB_LIBRARY}
)

aux_source_directory(${PROJECT_SOURCE_DIR}/libs SRC)

add_executable(run demo.cc ${SRC})